<template>
	<view class="page">
		<u-card padding="0" :border="false" margin="0" border-radius="0" :foot-border-top="false"
			:head-border-bottom="false">
			<view class="card-head" slot="head">询价单信息</view>
			<view class="card-body" slot="body">
				<view class="u-body-item">
					<view class="item">
						<view class="title">询价单编号:</view>
						<view class="info">{{enquiryVO.fagrmntid044||''}}</view>
					</view>
				</view>
				<view class="u-body-item">
					<view class="item">
						<view class="title">询价描述:</view>
						<view class="info">{{enquiryVO.fagrmntid044Text||''}}</view>
					</view>
				</view>
				<view class="u-body-item">
					<view class="item">
						<view class="title">询价有效期:</view>
						<view class="info">{{`${enquiryVO.rfqStart || "-"} 至 ${enquiryVO.rfqEnd || "-"}`}}</view>
					</view>
				</view>
				<!-- <view class="u-body-item">
					<view class="item">
						<view class="title">币别:</view>
						<view class="info">{{enquiryVO.docCurrency||''}}</view>
					</view>
				</view> -->
				<view class="u-body-item">
					<view class="item">
						<view class="title">货运协议有效期:</view>
						<view class="info">{{`${enquiryVO.validityStartTs || "-"} 至 ${enquiryVO.validityEndTs || "-"}`}}
						</view>
					</view>
				</view>
				<view class="u-body-item">
					<view class="item">
						<view class="title">询价响应截止日期:</view>
						<view class="info">{{enquiryVO.responseEnd||''}}</view>
					</view>
				</view>
			</view>
		</u-card>
		<u-card padding="0" :border="false" margin="0" border-radius="0" :foot-border-top="false"
			:head-border-bottom="false">
			<view class="card-head" slot="head">组织信息</view>
			<view class="card-body" slot="body">
				<view class="table">
					<view class="tr">
						<view class="th">组织单位</view>
						<view class="th">组织单位描述</view>
					</view>
					<view class="tr" v-for="(item,index) in enquiryOrgVO" :key="index">
						<view class="td">{{item.orgUnit||''}}</view>
						<view class="td">{{item.orgUnitText||''}}</view>

					</view>
				</view>
			</view>
		</u-card>
		<u-card padding="0" :border="false" margin="0" border-radius="0" :foot-border-top="false"
			:head-border-bottom="false">
			<view class="card-head" slot="head">询价项目信息</view>
			<view class="card-body" slot="body">
				<view class="table">
					<view class="tr">
						<view class="th">询价项目</view>
						<view class="th">币别</view>
						<view class="th">计算单描述</view>
						<view class="th">费用类型描述</view>
						<view class="th">费率表</view>
						<view class="th">操作</view>
					</view>
					<view class="tr" v-for="(item,index) in enquiryItemVO" :key="index">
						<view class="td">{{item.itemNo||''}}</view>
						<view class="td">{{item.docCurrency||''}}</view>
						<view class="td">{{item.tccsId047Text||''}}</view>
						<view class="td">{{item.tcet084Text||''}}</view>
						<view class="td">{{item.rateId||''}}</view>
						<view class="td" style="color: #007aff;" @click="view(item)">查看</view>
					</view>
				</view>
			</view>
		</u-card>
		<view class="footer">
			<view class="u-footer">
				<view></view>
				<u-button v-if="enquiryVO.enquiryStatus != 'abolished' &&enquiryVO.enquiryStatus != 'finish'"
					type="primary" size="medium" @click="submit()">提交</u-button>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				enquiryVO: {},
				id: "",
				enquiryOrgVO: [],
				enquiryItemVO: [],
			}
		},
		onLoad(option) {
			if (option.id) {
				this.id = option.id
				this.getData()
			}
		},
		methods: {
			getData() {
				uni.showLoading({
					title: '加载中'
				})
				this.$u.api.carrier.getInquiryDetail({
					id: this.id,
				}).then(data => {
					uni.hideLoading()
					if (data.code === 200 && data.success) {
						this.enquiryVO = data.data.enquiryVO;
						this.enquiryOrgVO = data.data.enquiryOrgVO;
						this.enquiryItemVO = data.data.enquiryItemVO;
					}
				}).catch(() => {
					uni.hideLoading()
				})
			},
			view(item) {
				uni.navigateTo({
					url: `./inquirItemDetail?id=${this.id}&itemId=${item.id}&itemNo=${item.itemNo}&enquiryStatus=${this.enquiryVO.enquiryStatus}`
				})
			},
			submit() {
				uni.showModal({
					title: `是否确定提交该询价?`,
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '加载中'
							})
							this.$u.api.carrier.submitInquiry(this.id).then(data => {
								uni.hideLoading()
								if (data.code === 200 && data.success) {
									this.$refs.uToast.show({
										title: data.msg,
										type: 'success',
										duration: 1000
									})
									this.getData()
								} else {
									this.$refs.uToast.show({
										title: data.msg,
										type: 'warning',
										duration: 1000
									})
								}
							}).catch(() => {
								uni.hideLoading()
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.page {
		min-height: 100vh;
		width: 750rpx;
		background-color: #f9f9f9;
		padding-top: 20rpx;
		padding-bottom: 40rpx;
		box-sizing: border-box;

		.card-head {
			color: $uni-color-primary;
			font-size: 38rpx;
			font-weight: 600;
			padding: 30rpx 0;
			width: 690rpx;
			margin: 0 auto;
			border-bottom: 4rpx solid $uni-color-primary;
		}

		.card-body {
			width: 750rpx;
			padding: 30rpx;
			box-sizing: border-box;

			.table {
				width: 100%;
				border: 2rpx solid #e4e7ed;
				display: table;

				.tr {
					width: 100%;
					display: table-row;

					:last-child {
						border-right-width: 0 !important;
					}

					.th {
						width: 16.66%;
						display: table-cell;
						vertical-align: middle;
						text-align: center;
						font-size: 28rpx;
						color: #303133;
						font-weight: bold;
						background-color: #f5f6f8;
						text-align: center;
						padding: 10rpx 6rpx;
						border-bottom: solid 2rpx #e4e7ed;
						border-right: solid 2rpx #e4e7ed;
						word-break: break-all;
					}

					.td {
						width: 16.66%;
						display: table-cell;
						vertical-align: middle;
						text-align: center;
						font-size: 26rpx;
						color: #606266;
						text-align: center;
						padding: 10rpx 6rpx;
						border-right: solid 2rpx #e4e7ed;
						word-break: break-all;
					}
				}
			}
		}

		.u-body-item {
			font-size: 28rpx;
			color: #999999;
			width: 100%;
			margin-bottom: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 750rpx;
			box-sizing: border-box;

			.item {
				display: flex;
				justify-content: flex-start;
				align-items: flex-start;

				.title {
					width: 260rpx;
				}

				.info {
					width: 430rpx;
					color: #333333;
					word-break: break-all;
				}
			}

		}

		.footer {
			width: 750rpx;
			padding: 30rpx;
			box-sizing: border-box;
			background-color: #fff;

			.u-footer {
				display: flex;
				justify-content: space-between;
			}
		}

	}
</style>
